package com.tang.imgupload.commen;

import lombok.Data;

@Data
public class CommenResult<T> {
	private Integer code;
	private String msg;
	private T data;

	public CommenResult(Constant.CommenResult state, T data){
		this.code = state.getCode();
		this.msg = state.getMsg();
		this.data = data;
	}

	public static CommenResult fail(){
		return new CommenResult(Constant.CommenResult.FAILED, null);
	}

	public static CommenResult succ(){
		return new CommenResult(Constant.CommenResult.SUCCESSFUL, null);
	}

	public static CommenResult failAndMsg(Constant.CommenResult state){
		return new CommenResult(state, null);
	}

	public static CommenResult succAndData(Object Data){
		return new CommenResult(Constant.CommenResult.SUCCESSFUL, Data);
	}

	public static CommenResult Result(Constant.CommenResult state, Object Data){
		return new CommenResult(state, Data);
	}
}
